/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.manchester.biology.eqhei.persistence;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author mlwyatt
 */
@Entity
@Table(name = "Section")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Section.findAll", query = "SELECT s FROM Section s"),
    @NamedQuery(name = "Section.findBySectionName", query = "SELECT s FROM Section s WHERE s.sectionPK.sectionName = :sectionName"),
    @NamedQuery(name = "Section.findByAttributeSetName", query = "SELECT s FROM Section s WHERE s.sectionPK.attributeSetName = :attributeSetName"),
    @NamedQuery(name = "Section.findByMaxScore", query = "SELECT s FROM Section s WHERE s.maxScore = :maxScore")})
public class Section implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SectionPK sectionPK;
    @Column(name = "maxScore")
    private Short maxScore;
    @OneToMany(mappedBy = "section")
    private Collection<EvaluationSection> evaluationSectionCollection;

    public Section() {
    }

    public Section(SectionPK sectionPK) {
        this.sectionPK = sectionPK;
    }

    public Section(String sectionName, String attributeSetName) {
        this.sectionPK = new SectionPK(sectionName, attributeSetName);
    }

    public SectionPK getSectionPK() {
        return sectionPK;
    }

    public void setSectionPK(SectionPK sectionPK) {
        this.sectionPK = sectionPK;
    }

    public Short getMaxScore() {
        return maxScore;
    }

    public void setMaxScore(Short maxScore) {
        this.maxScore = maxScore;
    }

    @XmlTransient
    public Collection<EvaluationSection> getEvaluationSectionCollection() {
        return evaluationSectionCollection;
    }

    public void setEvaluationSectionCollection(Collection<EvaluationSection> evaluationSectionCollection) {
        this.evaluationSectionCollection = evaluationSectionCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sectionPK != null ? sectionPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Section)) {
            return false;
        }
        Section other = (Section) object;
        if ((this.sectionPK == null && other.sectionPK != null) || (this.sectionPK != null && !this.sectionPK.equals(other.sectionPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.manchester.biology.eqhei.business.Section[ sectionPK=" + sectionPK + " ]";
    }
    
}
